<%@ page language="java" import="java.util.*,java.text.DecimalFormat" pageEncoding="utf-8" %>
<%@page import="com.entity.BulletinInfo" %>
<%@page import="com.util.PublicToolCheckParam" %>
<%@page import="com.entity.GoodsInfo" %>
<%@page import="com.dao.ThirdInfoDAO" %>
<%@page import="com.entity.ThirdInfo" %>
<%@page import="com.util.PublicToolGetGoodsTypeName" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <title>坐诊信息管理</title>
    <link type="text/css" rel="stylesheet" href="../css/style.css"/>
    <script type="text/javascript" src="../js/admin/manageGoodsInfo.js" charset="utf-8"></script>
</head>

<body>
<form action="../servlet/ManageGoodsInfo?method=deleteMore" method="post">
    <table width="100%" border="0" cellpadding="0" cellspacing="0" style="font-size:13px;">
        <tr>
            <td width="100%" height="36">
                <strong><font color="#666666" size="3">坐诊信息管理</font></strong>
            </td>
            <td height="36">
                <div align="right">
                    <input type="text" name="key" style="height: 24px;width: 250px;padding-top: 2px;padding-left:20px;background-image: url(../image/icon/key_search.gif);background-repeat: no-repeat"/>
                </div>
            </td>
            <td>
                <input type="button" value="查询" style="height: 26px;width: 70px;padding-top: 2px" onClick="return searchGoodsInfo()"/>
            </td>

        </tr>
        <tr>
            <td height="40" colspan="5">
                <hr width="100%"/>
            </td>
        </tr>
        <tr>
            <td height="147" colspan="12">
                <table width="100%" border="1" cellpadding="0" cellspacing="0" style="font-size:13px" bordercolor="#cccccc">
                    <tr height="30">

                        <td width="55">
                            <div align="center"><font color="#666666">坐诊编号</font></div>
                        </td>
                        <td width="85">
                            <div align="center"><font color="#666666">科室类别</font></div>
                        </td>
                        <td>
                            <div align="center"><font color="#666666">显示名称</font></div>
                        </td>
                        <td width="65">
                            <div align="center"><font color="#666666">挂号费用</font></div>
                        </td>
                        <td width="55">
                            <div align="center"><font color="#666666">发布时间</font></div>
                        </td>

                        <td width="110">
                            <div align="center"><font color="#666666">所属医生</font></div>
                        </td>
                        <td width="55">
                            <div align="center"><font color="#666666">坐诊信息状态</font></div>
                        </td>
                        <td>
                            <div align="center"><font color="#666666">审核状态</font></div>
                        </td>
                        <td width="70">
                            <div align="center"><font color="#666666">操作</font></div>
                        </td>
                    </tr>
                    <%
                        String isSearching = (String) request.getAttribute("isSearching");
                        ArrayList<GoodsInfo> goodsInfoList = (ArrayList<GoodsInfo>) request.getAttribute("goodsInfoList");
                        if (goodsInfoList == null || goodsInfoList.toString().equals("[]")) {
                            out.println("<td colspan='12' height='30'><div align='center'>当前无任何坐诊信息!</div></td>");
                        } else {
                            DecimalFormat df = new DecimalFormat("0.00");
                            for (int i = 0; i < goodsInfoList.size(); i++) {
                                GoodsInfo gd = goodsInfoList.get(i);
                                String goodsName = gd.getGoodsName();
                                if (goodsName.length() > 19) {
                                    goodsName = goodsName.substring(0, 18) + "...";
                                }
                                String price = df.format(gd.getPrice());
                                String createdate = gd.getCreatedate();
                                int countrequire = gd.getCountRequire();
                                String userid = gd.getUserid();
                                String thirdName = "";
                                if (userid == null) {
                                    thirdName = "管理员";
                                } else {


                                    ThirdInfoDAO udao = new ThirdInfoDAO();
                                    ThirdInfo ThirdInfo = udao.getThirdInfo(Integer.parseInt(userid));
                                    thirdName = ThirdInfo.getthirdName();

                                }

                                String status = "发布";
                                if (gd.getStatus() == 1) {
                                    status = "草稿";
                                }
                                out.println("<tr height='30'>");
                                    out.println("<td><div align='center'>" + gd.getGoodsId() + "</div></td>");

                                out.println("<td><div align='center'>" + PublicToolGetGoodsTypeName.getGoodDetailTypeName(Integer.parseInt(gd.getTypeDetailInfo())) + "</div></td>");
                                out.println("<td><div align='center'>" + goodsName + "</div></td>");
                                out.println("<td><div align='center'>￥" + price + "</div></td>");

                                out.println("<td><div align='center'>" + createdate + "</div></td>");
                                  out.println("<td><div align='center'>" + thirdName + "</div></td>");

                                out.println("<td><div align='center'>" + status + "</div></td>");
                                //out.println("<td><div align='center'>"+gd.getGoodsId()+"</div></td>");
                                if (gd.getIsCooled() == 1) {
                                    out.println("<td><div align='center'><font color='#FF0000'>未审核</font></div></td>");
                                } else {
                                    out.println("<td><div align='center'>已审核</div></td>");
                                }
                                out.println("<td><div align='center'>");
                                if (PublicToolCheckParam.checkNullAndEmpty(isSearching) && goodsInfoList.size() > 1) {
                                    out.println("<a href='../servlet/ManageGoodsInfo?method=update&goodsId=" + gd.getGoodsId() + "'>修改</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href='#' onclick=deleteGoodsInfoOfSearching(" + gd.getGoodsId() + "," + request.getAttribute("key") + ")>删除</a>");


                                    if (gd.getIsCooled() == 1) {
                                        out.println(" <a href='#' onclick=coolGoodsInfoOfSearching(" + gd.getGoodsId() + "," + gd.getIsCooled() + "," + request.getAttribute("key") + ")>审核通过</a>");
                                    } else {
                                        out.println(" <a href='#' onclick=coolGoodsInfoOfSearching(" + gd.getGoodsId() + "," + gd.getIsCooled() + "," + request.getAttribute("key") + ")>取消审核</a>");
                                    }


                                } else {
                                    out.println("<a href='../servlet/ManageGoodsInfo?method=update&goodsId=" + gd.getGoodsId() + "'>修改</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href='#' onclick=deleteGoodsInfo(" + gd.getGoodsId() + ")>删除</a>");

                                    if (gd.getIsCooled() == 1) {
                                        out.println(" <a href='#' onclick=coolGoodsInfo(" + gd.getGoodsId() + "," + gd.getIsCooled() + ")>审核通过</a>");
                                    } else {
                                        out.println(" <a href='#' onclick=coolGoodsInfo(" + gd.getGoodsId() + "," + gd.getIsCooled() + ")>取消审核</a>");
                                    }


                                }

                                out.println("</div></td></tr>");
                            }
                        }
                    %>
                    <tr>
                        <td colspan="13" height="50">
                            <div align="center">共找到<%=request.getAttribute("sumCount")%>条记录&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;第<%=request.getAttribute("currentPage")%>/<%=request.getAttribute("sumPageCount")%>页&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="../servlet/ManageGoodsInfo?method=<%if(PublicToolCheckParam.checkNullAndEmpty(isSearching)){out.println("search&key="+request.getAttribute("key")+"");}else{out.println("showManageGoodsInfoPage");}%>&cp=<%=request.getAttribute("indexPage")%>">首页</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="../servlet/ManageGoodsInfo?method=<%if(PublicToolCheckParam.checkNullAndEmpty(isSearching)){out.println("search&key="+request.getAttribute("key")+"");}else{out.println("showManageGoodsInfoPage");}%>&cp=<%=request.getAttribute("upPage")%>">上一页</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="../servlet/ManageGoodsInfo?method=<%if(PublicToolCheckParam.checkNullAndEmpty(isSearching)){out.println("search&key="+request.getAttribute("key")+"");}else{out.println("showManageGoodsInfoPage");}%>&cp=<%=request.getAttribute("nextPage")%>">下一页</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="../servlet/ManageGoodsInfo?method=<%if(PublicToolCheckParam.checkNullAndEmpty(isSearching)){out.println("search&key="+request.getAttribute("key")+"");}else{out.println("showManageGoodsInfoPage");}%>&cp=<%=request.getAttribute("lastPage")%>">尾页</a>
                            </div>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</form>
</body>
</html>
